import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)
// // 解决同一地址跳转报错,第一加载组件，第二次加载详情页面
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  { path: '/', redirect: '/projectlist' },
  {
    path: '/home',
    name: 'home',
    // redirect: '/projectlist',
    component: () => import('../components/Home.vue'),
    children: [
      {
        path: '/projectlist',
        name: 'projectlist',
        component: () => import('../components/ProjectList.vue')
      },
      // {
      //   path: '/project',
      //   name: 'project',
      //   component: () => import('../components/ApiGroup.vue'),
      // },
      {
        path: '/project/:d',
        name: 'apigroup',
        component: () => import('../components/ApiGroup.vue'),
        // children: [
        //   // {
        //   //   path: '/apilist',
        //   //   name: 'apilist',
        //   //   component: () => import('../components/ApiList.vue')
        //   // },
        // ]
      },

      {
        path: '/setting',
        name: 'setting',
        component: () => import('../components/Setting.vue')
      },
    ]
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
